package com.zzgele.qmzb.api.web;

import com.alibaba.boot.dubbo.annotation.DubboConsumer;
import com.zzgele.qmzb.api.core.Result;
import com.zzgele.qmzb.api.core.ResultCode;
import com.zzgele.qmzb.api.model.VideoStorage;
import com.zzgele.qmzb.api.service.VideoStorageService;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 视频存储 控制器
 * Created by e on 2017/11/4
 *
 * @author <a href="http://eregg.com">eregg</a>
 */
@RestController
@RequestMapping("/video")
public class VideoStorageController {

    private final Logger logger = LoggerFactory.getLogger(VideoStorageController.class);

    @DubboConsumer
    private VideoStorageService videoStorageService;

    /**
     * 视频存储
     * 传入 voideId 单个存储
     * 传入 时间戳 批存储
     * 存储完成，回调调用方，通知处理结果。
     * @param videoStorage
     * @return
     */
    @PostMapping("/storage")
    public Result singleStorage(@Valid VideoStorage videoStorage){

        logger.info(JSONObject.fromObject(videoStorageService).toString());

        videoStorageService.storage(videoStorage);

        return new Result().setCode(ResultCode.SUCCESS);
    }


}
